#delimit;

clear;
capture log close;
set mem 300000;
set mat 700;

set more off;



log using "C:\Old C Drive\F\INTIKAM2009\RESTAT\WEB_Final\RESTATWEB\Table9_G.log",replace;


use "C:\Old C Drive\F\INTIKAM2009\RESTAT\WEB_Final\RESTATWEB\Fig7data1" ;



local personal " rgdpch male gun_coll up50 edu avrburgtly_region  
_20to24age _25to29age _30to34age _35to39age _40to44age _45to49age _50to54age _55to59age  _60to64age 
_65to69age _70plusage single widow livtogether divorced  working lookforjob homekeeper ret_disab";

local country_level "country1-country63
europe c_europe mediter newasia2 africa lat_amer year1-year11";



local dependents "gotopris2 ";
foreach varr of varlist `dependents' {;
gen dfdx_`var'_`varr'=.;
gen se_dfdx_`var'_`varr'=.;

forval x=5/9 {;
dprobit `varr' burgtly   `personal' `country_level' if EDU_DU==`x' & rgdpch>12000
[pweight=w005] ,robust cluster(count_code);
mat define dd=e(dfdx);
mat define se_d=e(se_dfdx);
replace dfdx_`var'_`varr'=dd[1,1] if EDU_DU==`x';
replace se_dfdx_`var'_`varr'=se_d[1,1] if EDU_DU==`x';
matrix drop dd se_d;
};

};




log close;
